﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterCar.master" AutoEventWireup="true" 
    CodeFile="promo-car-quote.aspx.cs" Inherits="car_insurance_promo_car_quote" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link rel="stylesheet" type="text/css" href="../js/fancy-box/jquery.fancybox.css"
        media="screen" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="divLoading" style="position: fixed; top: 0; left: 0; background-color: gray;
        filter: alpha(opacity=90); opacity: 0.8; width: 100%; height: 100%; display: none;">
        <table style="width: 100%; height: 300px">
            <tr>
                <td align="center" valign="middle">
                    <img src="../images/loader/loader.gif" alt="Loading" width="66" height="66" align="absmiddle" />
                </td>
            </tr>
        </table>
    </div>
    <div id="divCarYear" runat="server">
        <div class="container">
            <div style="position: absolute; margin-top: 9px; margin-left: 170px;">
                <asp:Image ID="imgMonkyCYR" runat="server" AlternateText="" Width="133" Height="111"
                    ImageUrl="" />
            </div>
            <div class="car-year-box">
                <div class="heading-radius">
                    <asp:Label ID="lblCarYearTitle" runat="server" Text=""></asp:Label>
                </div>
                <div id="ltrCarYear" runat="server">
                </div>
            </div>
        </div>
    </div>
    <div id="divCarMake" runat="server" style="display: none;">
        <div class="container">
            <div style="position: absolute; margin-top: 9px; margin-left: 170px;">
                <asp:Image ID="imgMonkyCMK" runat="server" AlternateText="" Width="133" Height="111"
                    ImageUrl="" />
            </div>
            <div class="car-year-box">
                <div class="heading-radius">
                    <asp:Label ID="lblCarMakeTitle" runat="server" Text="" Width="200px"></asp:Label>
                    <a onclick="return CarYearClick();" style="display: inline block; position: absolute;
                        float: inherit; color: #ddcf32;">Back</a>
                </div>
                <div id="ltrCarMake">
                </div>
            </div>
        </div>
    </div>
    <div id="divCarModel" runat="server" style="display: none;">
        <div class="container">
            <div style="position: absolute; margin-top: 9px; margin-left: 170px;">
                <asp:Image ID="imgMonkyCMM" runat="server" AlternateText="" Width="133" Height="111"
                    ImageUrl="" />
            </div>
            <div class="car-year-box">
                <div class="heading-radius" style="display: inline block;">
                    <asp:Label ID="lblCarModelTitle" runat="server" Text="" Width="200px"></asp:Label>
                    <a onclick="return CarMakeClick();" style="display: inline block; position: absolute;
                        float: inherit; color: #ddcf32;">Back</a>
                </div>
                <div id="ltrCarModel">
                </div>
            </div>
        </div>
    </div>
    <div id="divCommence" runat="server" style="display: none;">
        <div class="container">
            <div style="position: absolute; margin-top: 9px; margin-left: 170px;">
                <img src="../images/monkey-chac.png" width="133" height="111" alt="" />
            </div>
            <div class="car-year-box">
                <div class="heading-radius">
                    <asp:Label ID="lblCommencementTitle" runat="server" Text=""></asp:Label>
                </div>
                <div id="ltrCommencement" runat="server">
                </div>
            </div>
            <div class="dbd-oic-hor-chac">
                <img src="../images/dbd-oic-hor-chac.jpg" width="283" height="137" alt="" /></div>
        </div>
    </div>
    <div class="call-button" style="width:225px; margin: 10px auto;">
                <a href="tel:tel:022688222">
                    <img src="../images/call-button.png" width="225" height="51" alt="" /></a></div>
    <div style="width: 280px; margin: auto; padding-bottom: 10px;" id="divPromo" runat="server"
        visible="false">
        <img src="<%=GetGlobalResourceObject("CarMenu", "ImgCNYPromoInnerUrl")%>" width="280"
            height="300" alt="" />
    </div>    
    <div class="dbd-oic-hor-chac" style="width:283px; margin: 10px auto;">
        <img src="<%=GetGlobalResourceObject("CarMenu", "ImgDBDOICHorUrl")%>" width="283"
            height="137" alt="" /></div>
    <div>
        <asp:HiddenField ID="hdnUserLoginStatus" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarYear" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarMake" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarMakeDesc" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarModel" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarModelDesc" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCommence" runat="server" Value="0" />
        <asp:HiddenField ID="lblSumInsured" runat="server" Value="0" />
        <asp:HiddenField ID="txtSumInsured" runat="server" Value="0" />
        <asp:HiddenField ID="lblCarVehicleType" runat="server" Value="0" />
        <asp:HiddenField ID="txtGroupNo" runat="server" Value="-1" />
        <asp:HiddenField ID="ddlVehicleType" runat="server" Value="110" />
        <asp:HiddenField ID="hdnIsPromo" runat="server" Value="0" />
    </div>
    <asp:HiddenField runat="server" ID="hdnURLFrom" Value="" />

    <script type="text/javascript">

        $('#CarYear li').click(function(event) {
            event.preventDefault();
            var rel = $(this).attr('rel');
            if (rel != null && rel != "0") {
                document.getElementById('<%= hdnCarYear.ClientID%>').value = rel;
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "promo-car-quote.aspx/CarYearClickChanged",
                    data: "{Year:" + rel + ", 'language': '" + '<%=Session["Language"].ToString()%>' + "'}",
                    dataType: "json",
                    success: function(data) {
                        //alert(data.d);
                        var result = data.d;
                        document.getElementById('ltrCarMake').innerHTML = result;
                        CarMakeClick();
                    },
                    error: function(result) {
                        //alert("Error");
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCarYear.ClientID%>').value = "0";
            }
        });

        function my(myvalue) {
            var rel = $(myvalue).attr('rel');
            var makedesc = $(myvalue).text();
            //alert(makedesc);
            if (rel != null && rel != '0' && makedesc != null && makedesc != '0') {
                document.getElementById('<%= hdnCarMake.ClientID%>').value = rel;
                document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = makedesc;
                //alert(rel);
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;

                $.ajax({
                url: "promo-car-quote.aspx/CarMakeClickChanged",
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify({ CarMake: rel, CarMakeDesc: makedesc, Year: year, language: '<%=Session["Language"].ToString()%>' }),
                    success: function(data) {
                        var result = data.d;
                        document.getElementById('ltrCarModel').innerHTML = result;
                        CarModelClick();
                    },
                    error: function(result) {
                        //alert("Error");
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCarMake.ClientID%>').value = "0";
                document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = "0";
            }
        }

        $('#ltrCarMake #CarMake').on('click', '.carmake2', function() {
            //$('#CarMake li').click(function (event) {

            //event.stopPropagation();
            //event.preventDefault();
            //alert('hiu');
            var rel = $(this).attr('rel');
            var makedesc = $(this).text();
            if (rel != null && rel != '0' && makedesc != null && makedesc != '0') {
                document.getElementById('<%= hdnCarMake.ClientID%>').value = rel;
                document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = makedesc;
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                //alert(year);
                //alert(makedesc);
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "promo-car-quote.aspx/CarMakeClickChanged",
                    data: "{CarMake:" + rel + ",CarMakeDesc:" + makedesc + ",Year:" + year + "}",
                    dataType: "json",

                    success: function(data) {
                        //alert(data);
                        //alert(data.d);
                        var result = data.d;
                        document.getElementById('ltrCarModel').innerHTML = result;
                        CarModelClick();
                    },
                    error: function(result) {
                        //alert("Error");
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCarMake.ClientID%>').value = "0";
                document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = "0";
            }
        });


        function mo(myvalue) {
            ShowHideDiv('divLoading', true);
            var rel = $(myvalue).attr('rel');
            //var modeldesc = $(myvalue).text();
            var modeldesc = rel;
            if (rel != null && rel != '0' && modeldesc != null && modeldesc != '0') {
                document.getElementById('<%= hdnCarModel.ClientID%>').value = rel;
                document.getElementById('<%= hdnCarModelDesc.ClientID%>').value = modeldesc;
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                var urlfrom = document.getElementById('<%= hdnURLFrom.ClientID%>').value;
                var islogin = document.getElementById('<%= hdnUserLoginStatus.ClientID%>').value;
                //alert(year);
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    //url: "car-quote.aspx/CarModelClickChanged",
                    url: "promo-car-quote.aspx/SaveMobileCarInquiry",
                    data: JSON.stringify({ Year: year, CarMake: make, CarMakeDesc: makedesc, CarModel: rel, CarModelDesc: modeldesc, URLFrom: urlfrom }),
                    dataType: "json",

                    success: function(data) {
                        //alert(data.d);
                        var myString = data.d;
                        var arr = myString.split(':');
                        var domain = window.location.hostname;
                        //alert(domain);
                        if (islogin == "1") {
                            window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        }
                        else {
//                            window.location.href = "promo-your-details.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        }
                    },
                    error: function(result) {
                        //alert("Error");
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCarModel.ClientID%>').value = "0";
            }
        }

        $('#ltrCarModel #CarModel').on('click', '.carmodel2', function() {
            ShowHideDiv('divLoading', true);
            //$('#CarModel li').click(function() {
            var rel = $(this).attr('rel');
            //var modeldesc = $(this).text();
            var modeldesc = rel;
            if (rel != null && rel != '0' && modeldesc != null && modeldesc != '0') {
                document.getElementById('<%= hdnCarModel.ClientID%>').value = rel
                document.getElementById('<%= hdnCarModelDesc.ClientID%>').value = modeldesc;
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                var urlfrom = document.getElementById('<%= hdnURLFrom.ClientID%>').value;
                var islogin = document.getElementById('<%= hdnUserLoginStatus.ClientID%>').value;
                //alert(year);
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    //url: "car-quote.aspx/CarModelClickChanged",
                    url: "promo-car-quote.aspx/SaveMobileCarInquiry",
                    data: "{Year:" + year + ",CarMake:" + make + ",CarMakeDesc:" + makedesc + ",CarModel:" + rel + ",CarModelDesc:" + modeldesc + ",URLFrom:" + urlfrom + "}",
                    dataType: "json",

                    success: function(data) {
                        //alert(data.d);
                        var myString = data.d;
                        var arr = myString.split(':');
                        var domain = window.location.hostname;
                        //alert(domain);
                        if (islogin == "1") {
                            window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        }
                        else {
//                            window.location.href = "promo-your-details.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        }
                    },
                    error: function(result) {
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCarModel.ClientID%>').value = "0";
            }
        });

        //------------------------------------------------//

        function cm(myvalue) {
            var rel = $(myvalue).attr('rel');
            if (rel != null && rel != '0') {
                document.getElementById('<%= hdnCommence.ClientID%>').value = rel;
                //alert(rel);
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                var model = document.getElementById('<%= hdnCarModel.ClientID%>').value;
                var modeldesc = document.getElementById('<%= hdnCarModelDesc.ClientID%>').value;
                var suminsured = document.getElementById('<%= txtSumInsured.ClientID%>').value;
                var carvehicletype = document.getElementById('<%= lblCarVehicleType.ClientID%>').value;
                var vehicletype = document.getElementById('<%= ddlVehicleType.ClientID%>').value;
                var groupno = document.getElementById('<%= txtGroupNo.ClientID%>').value;

                $.ajax({
                url: "promo-car-quote.aspx/SaveMobileCarInquiry",
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify({ Year: year, CarMake: make, CarMakeDesc: makedesc, CarModel: model, CarModelDesc: modeldesc, Commencemonth: rel, GroupNo: groupno, CarVehicleType: carvehicletype, VehicleType: vehicletype, SumInsured: suminsured }),
                    success: function(data) {
                        var myString = data.d;
                        //alert(data.d);
                        var arr = myString.split(':');
                        var domain = window.location.hostname;
                        //alert(domain);
                        window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                    },
                    error: function(result) {
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCommence.ClientID%>').value = "0";
            }
        }

        $('#ltrCommencement #Commencement').on('click', '.commance2', function() {
            var rel = $(this).attr('rel');
            if (rel != null && rel != '0') {
                document.getElementById('<%= hdnCommence.ClientID%>').value = rel;
                var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                var model = document.getElementById('<%= hdnCarModel.ClientID%>').value;
                var modeldesc = document.getElementById('<%= hdnCarModelDesc.ClientID%>').value;
                var suminsured = document.getElementById('<%= txtSumInsured.ClientID%>').value;
                var carvehicletype = document.getElementById('<%= lblCarVehicleType.ClientID%>').value;
                var vehicletype = document.getElementById('<%= ddlVehicleType.ClientID%>').value;
                var groupno = document.getElementById('<%= txtGroupNo.ClientID%>').value;
                alert(year);
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "promo-car-quote.aspx/SaveMobileCarInquiry",
                    data: "{Year:" + year + ",CarMake:" + make + ",CarMakeDesc:" + makedesc + ",CarModel:" + model + ",CarModelDesc:" + modeldesc + ",Commencemonth:" + rel + ",GroupNo:" + groupno + ",CarVehicleType:" + carvehicletype + ",VehicleType:" + vehicletype + ",SumInsured:" + suminsured + "}",
                    dataType: "json",

                    success: function(data) {
                        //alert(data.d);
                        var myString = data.d;
                        //alert(data.d);
                        var arr = myString.split(':');
                        var domain = window.location.hostname;
                        //alert(domain);
                        window.location.href = "promo-results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                    },
                    error: function(result) {
                    }
                });
            }
            else {
                document.getElementById('<%= hdnCommence.ClientID%>').value = "0";
            }
        });


    </script>

    <script type="text/javascript">

        function ShowHideDiv(divName, varOnOff) {
            if (varOnOff) {
                document.getElementById(divName).style.display = "";
            }
            else {
                document.getElementById(divName).style.display = "none";
            }
        }

        function CarYearClick() {
            document.getElementById('<%= divCarYear.ClientID%>').style.display = '';
            document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';

        }
        function CarMakeClick() {
            document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarMake.ClientID%>').style.display = '';
            document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';

        }
        function CarModelClick() {
            document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarModel.ClientID%>').style.display = '';
            document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';
        }
        function CommenceClick() {
            document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
            document.getElementById('<%= divCommence.ClientID%>').style.display = '';
        }
            
    </script>

</asp:Content>

